//
//  ImageShowViewController.m
//  TestAnimation
//
//  Created by longpeng on 15/3/19.
//  Copyright (c) 2015年 longpeng. All rights reserved.
//

#import "ImageShowViewController.h"




#define ZSScreenW  [UIScreen mainScreen].bounds.size.width
#define ZSScreenH  [UIScreen mainScreen].bounds.size.height

@interface ImageShowViewController ()
{
    
    UIControl *backControl;
    
    UIButton *okokbrn;
}
@end

@implementation ImageShowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
   // self.view.backgroundColor=[UIColor cyanColor];

    NSLog(@"修改数据了啊");
   
    NSLog(@"再次修改数据");
    
    NSLog(@"sender merge");
    
    NSLog(@"release version");
    backControl =[[UIControl alloc]init];
    backControl.center=CGPointMake(ZSScreenW/2, ZSScreenH/2);
    backControl.bounds=CGRectMake(0, 0, ZSScreenW, ZSScreenH);
    [backControl addTarget:self action:@selector(clickControl:) forControlEvents:UIControlEventTouchUpInside];
    backControl.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5];
    //[self.view addSubview:backControl];
    
    [backControl addSubview:self.LblOne];
    [backControl addSubview:self.lblTwo];
    [backControl addSubview:self.lblThree];
    
   // [backControl addSubview:self.addbtn];

    
    // [self.view insertSubview:backControl belowSubview:self.addbtn];
    
    okokbrn =[[UIButton alloc]init];
    okokbrn.frame=CGRectMake(100, 300, 40, 40);
   // okokbrn.backgroundColor=[UIColor redColor];
    [okokbrn addTarget:self action:@selector(backbtn:) forControlEvents:UIControlEventTouchUpInside];
    [okokbrn setBackgroundImage:[UIImage imageNamed:@"task.png"] forState:UIControlStateNormal];

   // [self.view addSubview:okokbrn];
    
    [[[UIApplication sharedApplication ].windows firstObject] addSubview:backControl];
    
    [[[UIApplication sharedApplication ].windows firstObject] addSubview:okokbrn];
    
    
    [[[UIApplication sharedApplication ].windows firstObject] bringSubviewToFront:okokbrn];

   // self.LblOne.center=CGPointMake(ZSScreenW/2, 1000);
   // self.LblOne.bounds=CGRectMake(0, 0, 180, 60);
   // self.lblTwo.center=CGPointMake(ZSScreenW/2, 1000);
   // self.lblTwo.bounds=CGRectMake(0, 0, 180, 60);
   // self.lblThree.center=CGPointMake(ZSScreenW/2, 1000);
   // self.lblThree.bounds=CGRectMake(0, 0, 180, 60);

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)backbtn:(id)sender {
    
    NSLog(@"back btn click ");
    
    static int number =0;
    
    if (number%2==0) {
        NSLog(@"00000");
       /*
        [UIView animateWithDuration:1 animations:^{
            self.LblOne.center=CGPointMake(ZSScreenW/2, 1000);
            self.LblOne.bounds=CGRectMake(0, 0, 180, 60);
            
            self.lblTwo.center=CGPointMake(ZSScreenW/2, 1000);
            self.lblTwo.bounds=CGRectMake(0, 0, 180, 60);
            
            self.lblThree.center=CGPointMake(ZSScreenW/2, 1000);
            self.lblThree.bounds=CGRectMake(0, 0, 180, 60);

        }];
        */
        
        self.addbtn.layer.affineTransform=CGAffineTransformMakeRotation(M_PI*0.25);
        
        okokbrn.layer.affineTransform=CGAffineTransformMakeRotation(M_PI*0.25);

        [UIView animateWithDuration:1 animations:^{
            self.LblOne.center=CGPointMake(ZSScreenW/2, 1000);
            self.LblOne.bounds=CGRectMake(0, 0, 60, 20);
            
        } completion:^(BOOL finished) {
            [UIView animateWithDuration:1 animations:^{
                self.lblTwo.center=CGPointMake(ZSScreenW/2, 1000);
                self.lblTwo.bounds=CGRectMake(0, 0, 60, 20);
            } completion:^(BOOL finished) {
                [UIView animateWithDuration:1 animations:^{
                    self.lblThree.center=CGPointMake(ZSScreenW/2, 1000);
                    self.lblThree.bounds=CGRectMake(0, 0, 60, 20);
                    backControl.center=CGPointMake(ZSScreenW/2, 1000);
                    backControl.bounds=CGRectMake(0, 0,ZSScreenW, ZSScreenH);

                } completion:^(BOOL finished) {
                    
//                      self.LblOne.center=CGPointMake(ZSScreenW/2, 1000);
//                      self.LblOne.bounds=CGRectMake(0, 0, 60, 20);
//                         self.lblTwo.center=CGPointMake(ZSScreenW/2, 1000);
//                         self.lblTwo.bounds=CGRectMake(0, 0, 60, 20);
//                            self.lblThree.center=CGPointMake(ZSScreenW/2, 1000);
//                            self.lblThree.bounds=CGRectMake(0, 0, 60, 20);

                    
                 }];
            }];
        }];

        
        
        
    }else if(number%2==1)
        
    {
        NSLog(@"111");

        
        

        
        
        self.addbtn.layer.affineTransform=CGAffineTransformMakeRotation(M_PI*0.5);
        okokbrn.layer.affineTransform=CGAffineTransformMakeRotation(M_PI*0.5);

        

        [UIView animateWithDuration:1 animations:^{
           // [backControl addSubview:self.addbtn];

            backControl.center=CGPointMake(ZSScreenW/2, ZSScreenH/2);
            backControl.bounds=CGRectMake(0, 0,ZSScreenW, ZSScreenH);
  
            
            self.LblOne.center=CGPointMake(ZSScreenW/4, 300);
            self.LblOne.bounds=CGRectMake(0, 0, 60, 20);

        } completion:^(BOOL finished) {
            [UIView animateWithDuration:1 animations:^{
                self.lblTwo.center=CGPointMake(ZSScreenW*0.5, 200);
                self.lblTwo.bounds=CGRectMake(0, 0, 60, 20);
            } completion:^(BOOL finished) {
                [UIView animateWithDuration:1 animations:^{
                    self.lblThree.center=CGPointMake(ZSScreenW*0.75, 300);
                    self.lblThree.bounds=CGRectMake(0, 0, 60, 20);
                } completion:^(BOOL finished) {

                }];
            }];
        }];

        
        /*
        
        [UIView animateWithDuration:1 animations:^{

        self.LblOne.center=CGPointMake(ZSScreenW/2, 100);
        self.LblOne.bounds=CGRectMake(0, 0, 180, 60);
        
        
        self.lblTwo.center=CGPointMake(ZSScreenW/2, 200);
        self.lblTwo.bounds=CGRectMake(0, 0, 180, 60);
        
        self.lblThree.center=CGPointMake(ZSScreenW/2, 300);
        self.lblThree.bounds=CGRectMake(0, 0, 180, 60);

        }];

        */
    }
        
    
    
    
    number++;
    
    
    
    
    
    
}


-(void)clickControl:(UIControl *)sender
{
    
    NSLog(@"werqw");
    
    
    
}





@end
